/**

*/
var SkinSelectSimple = new Class({
	
	//required: ["!ie6"],
	
	Implements: [Options, Events],

	options: {},
	
	
    initialize : function (element, options){
		this.setOptions(options)
		this.select = $(element);
		this.isOpen = false;
		this.span = new Element("span", {"class": this.select.className})
		this.span.inject(this.select, "before");
		
		this.select.addEvent("change", function (){
			this.setText();
		}.bind(this));
		
		if(!window["skinSelectSimpleEvent"]){
			window["skinSelectSimpleEvent"] = function (){
				$$('span.skinSelectSimpleOpen').each(function (el){el.removeClass('skinSelectSimpleOpen')});;
			}
		}
		
		$(document.body).addEvent('click', window["skinSelectSimpleEvent"]);
		//$(document.body).removeEvent('click', window["skinSelectSimpleEvent"]);
		
		this.select.addEvent("click", function (e){
			e.stop();
			
			this.span.hasClass('skinSelectSimpleOpen') ?
				this.span.removeClass('skinSelectSimpleOpen'):
				this.span.addClass('skinSelectSimpleOpen');
			
			this.select.hasClass('skinSelectSimpleOpen') ?
				this.select.removeClass('skinSelectSimpleOpen'):
				this.select.addClass('skinSelectSimpleOpen');
			
		}.bind(this))

		this.setText();
	},
	
	setText: function(){
		this.span.set('text', this.select.options[this.select.selectedIndex].innerHTML);
	},
	
	setSize: function (){
		this.span.setStyles(this.select.getStyles("width", "height", "border", "margin", "padding"));
	}
});
Moodule.register("SkinSelectSimple","select.skinSelectSimple");